package com.knowledge.business.controller;


import java.util.Arrays;
import java.util.List;
import java.io.IOException;

import com.knowledge.common.annotation.Log;
import com.knowledge.common.core.controller.BaseController;
import com.knowledge.common.core.domain.AjaxResult;
import com.knowledge.common.enums.BusinessType;
import com.knowledge.common.utils.poi.ExcelUtil;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.knowledge.business.domain.TPushQuestion;
import com.knowledge.business.service.ITPushQuestionService;
import com.knowledge.common.core.page.TableDataInfo;

/**
 * 推送问题Controller
 *
 * @author zhaoyk
 * @date 2025-11-24
 */
@RestController
@RequestMapping("/business/pushquestion")
public class TPushQuestionController extends BaseController {
    @Autowired
    private ITPushQuestionService tPushQuestionService;

/**
 * 查询推送问题列表
 */
//@RequiresPermissions("business:pushquestion:list")
@GetMapping("/list")
    public TableDataInfo list(TPushQuestion tPushQuestion) {
        startPage();
        List<TPushQuestion> list = tPushQuestionService.selectTPushQuestionList(tPushQuestion);
        return getDataTable(list);
    }

    /**
     * 导出推送问题列表
     */
    //@RequiresPermissions("business:pushquestion:export")
    @Log(title = "推送问题", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TPushQuestion tPushQuestion) {
        List<TPushQuestion> list = tPushQuestionService.selectTPushQuestionList(tPushQuestion);
        ExcelUtil<TPushQuestion> util = new ExcelUtil<TPushQuestion>(TPushQuestion. class);
        util.exportExcel(response, list, "推送问题数据");
    }

    /**
     * 获取推送问题详细信息
     */
    //@RequiresPermissions("business:pushquestion:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return AjaxResult.success(tPushQuestionService.getById(id));
    }

    /**
     * 新增推送问题
     */
    //@RequiresPermissions("business:pushquestion:add")
    @Log(title = "推送问题", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TPushQuestion tPushQuestion) {
        return toAjax(tPushQuestionService.save(tPushQuestion));
    }

    /**
     * 修改推送问题
     */
    //@RequiresPermissions("business:pushquestion:edit")
    @Log(title = "推送问题", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TPushQuestion tPushQuestion) {
        return toAjax(tPushQuestionService.updateById(tPushQuestion));
    }

    /**
     * 删除推送问题
     */
    //@RequiresPermissions("business:pushquestion:remove")
    @Log(title = "推送问题", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(tPushQuestionService.removeByIds(Arrays.asList(ids)));
    }
}
